'use strict';

const fs = require('fs')
const {BASEDIR} = require('../../../config')

const VERSION = 'v1'
const API_PREFIX = `/${VERSION}`
const routes = fs.readdirSync(`${BASEDIR}/routes`)


module.exports = {
    VERSION,
    success: /\"success\"\: true/,
    error: /.*/,
    modules: routes.reduce(function(rs, file) {
        if (/^\S*\.js$/.test(file)) {
            const module = file.replace(/\.js/, '')
            const uri = `${API_PREFIX}/${module}`
            rs[module.toUpperCase()] = uri
        }
        return rs
    }, {})
}